//
//  MBDUploadGroupTypeDetailCellModel.swift
//  MasterBoy
//
//  Created by kyson on 2024/9/5.
//

import Foundation

import YYText

class MBDUploadGroupTypeDetailCellModel: MBDUploadGroupBaseCellModel {
    static let Wechat = "1"
    
    static let clickToSetGroupType = "点此设置群类型"
    
    override func isEmpty() -> Bool {
        return text == MBDUploadGroupTypeDetailCellModel.clickToSetGroupType || text?.isBlank == true
    }
    
    override func nextVCTitle() -> String! {
        return "设置群类型"
    }
    
    
    override var text: String? {
       didSet {
           var info : String = self.text ?? " " //多一个字符，为了占位
           if text == MBDUploadGroupTypeDetailCellModel.Wechat {
               info = "微信"
           }
           let titleAttributeString = NSMutableAttributedString(string: info )
           titleAttributeString.yy_font = UIFont.systemFont(ofSize: 14)
           titleAttributeString.yy_color = UIColor(colorHex: 0x333333)
           titleAttributeString.yy_lineSpacing = 6

           let userNamecontainer = YYTextContainer()
           let userNameWidth = CGRectGetWidth(UIScreen.main.bounds) - 30
           userNamecontainer.size = CGSizeMake(userNameWidth , CGFLOAT_MAX)
           userNamecontainer.maximumNumberOfRows = 0

           let titleLayout = YYTextLayout(container: userNamecontainer, text: titleAttributeString)
           self.textlayout = titleLayout
           
           self.cellHeight = 10 + titleLayout!.textBoundingSize.height + 10
       }
   }
}
